home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_061 / microemacs / vt52.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  170 lines

  1. /*
  2.  * The routines in this file
  3.  * provide support for VT52 style terminals
  4.  * over a serial line. The serial I/O services are
  5.  * provided by routines in "termio.c". It compiles
  6.  * into nothing if not a VT52 style device. The
  7.  * bell on the VT52 is terrible, so the "beep"
  8.  * routine is conditionalized on defining BEL.
  9.  */
  10. #define    termdef    1            /* don't define "term" external */
  11.  
  12. #include        <stdio.h>
  13. #include        "estruct.h"
  14. #include    "edef.h"
  15.  
  16. #if     VT52
  17.  
  18. #define NROW    24                      /* Screen size.                 */
  19. #define NCOL    80                      /* Edit if you want to.         */
  20. #define    MARGIN    8            /* size of minimim margin and    */
  21. #define    SCRSIZ    64            /* scroll size for extended lines */
  22. #define    NPAUSE    100            /* # times thru update to pause */
  23. #define BIAS    0x20                    /* Origin 0 coordinate bias.    */
  24. #define ESC     0x1B                    /* ESC character.               */
  25. #define BEL     0x07                    /* ascii bell character         */
  26.  
  27. extern  int     ttopen();               /* Forward references.          */
  28. extern  int     ttgetc();
  29. extern  int     ttputc();
  30. extern  int     ttflush();
  31. extern  int     ttclose();
  32. extern  int     vt52move();
  33. extern  int     vt52eeol();
  34. extern  int     vt52eeop();
  35. extern  int     vt52beep();
  36. extern  int     vt52open();
  37. extern    int    vt52rev();
  38. extern    int    vt52kopen();
  39. extern    int    vt52kclose();
  40.  
  41. #if    COLOR
  42. extern    int    vt52fcol();
  43. extern    int    vt52bcol();
  44. #endif
  45.  
  46. /*
  47.  * Dispatch table. All the
  48.  * hard fields just point into the
  49.  * terminal I/O code.
  50.  */
  51. TERM    term    = {
  52.     NROW-1,
  53.         NROW-1,
  54.         NCOL,
  55.         NCOL,
  56.     MARGIN,
  57.     SCRSIZ,
  58.     NPAUSE,
  59.         &vt52open,
  60.         &ttclose,
  61.     &vt52kopen,
  62.     &vt52kclose,
  63.         &ttgetc,
  64.         &ttputc,
  65.         &ttflush,
  66.         &vt52move,
  67.         &vt52eeol,
  68.         &vt52eeop,
  69.         &vt52beep,
  70.         &vt52rev
  71. #if    COLOR
  72.     , &vt52fcol,
  73.     &vt52bcol
  74. #endif
  75. };
  76.  
  77. vt52move(row, col)
  78. {
  79.         ttputc(ESC);
  80.         ttputc('Y');
  81.         ttputc(row+BIAS);
  82.         ttputc(col+BIAS);
  83. }
  84.  
  85. vt52eeol()
  86. {
  87.         ttputc(ESC);
  88.         ttputc('K');
  89. }
  90.  
  91. vt52eeop()
  92. {
  93.         ttputc(ESC);
  94.         ttputc('J');
  95. }
  96.  
  97. vt52rev(status)    /* set the reverse video state */
  98.  
  99. int status;    /* TRUE = reverse video, FALSE = normal video */
  100.  
  101. {
  102.     /* can't do this here, so we won't */
  103. }
  104.  
  105. #if    COLOR
  106. vt52fcol()    /* set the forground color [NOT IMPLIMENTED] */
  107. {
  108. }
  109.  
  110. vt52bcol()    /* set the background color [NOT IMPLIMENTED] */
  111. {
  112. }
  113. #endif
  114.  
  115. vt52beep()
  116. {
  117. #ifdef  BEL
  118.         ttputc(BEL);
  119.         ttflush();
  120. #endif
  121. }
  122.  
  123. vt52open()
  124. {
  125. #if     V7 | BSD
  126.         register char *cp;
  127.         char *getenv();
  128.  
  129.         if ((cp = getenv("TERM")) == NULL) {
  130.                 puts("Shell variable TERM not defined!");
  131.                 exit(1);
  132.         }
  133.         if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) {
  134.                 puts("Terminal type not 'vt52'or 'z19' !");
  135.                 exit(1);
  136.         }
  137. #endif
  138.         ttopen();
  139. }
  140.  
  141. vt52kopen()
  142.  
  143. {
  144. }
  145.  
  146. vt52kclose()
  147.  
  148. {
  149. }
  150.  
  151.  
  152. #if    FLABEL
  153. fnclabel(f, n)        /* label a function key */
  154.  
  155. int f,n;    /* default flag, numeric argument [unused] */
  156.  
  157. {
  158.     /* on machines with no function keys...don't bother */
  159.     return(TRUE);
  160. }
  161. #endif
  162. #else
  163.  
  164. vt52hello()
  165.  
  166. {
  167. }
  168.  
  169. #endif
  170.